﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SUNAT.Entities;
using System.Data.SqlClient;
using System.Data;

namespace SUNAT.DataAccess
{
    public class DAOTRegistro
    {

        public int Create(BEIngresoTRegistro _BEIngresoTRegistro)
        {
            try
            {

                SqlCommand sqlCommand = new SqlCommand("SP_REGISTRAR_INGRESO_TREGISTRO");
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.Add(new SqlParameter("@NUMERODOCUMENTO", _BEIngresoTRegistro.NUMERODOCUMENTO));
                sqlCommand.Parameters.Add(new SqlParameter("@IDDOCIDENTIDAD", _BEIngresoTRegistro.IDDOCIDENTIDAD));

                sqlCommand.Parameters.Add(new SqlParameter("@IDDEPDOMICILIO", _BEIngresoTRegistro.IDDEPDOMICILIO));
                sqlCommand.Parameters.Add(new SqlParameter("@IDPROVDOMICILIO", _BEIngresoTRegistro.IDPROVDOMICILIO));

                sqlCommand.Parameters.Add(new SqlParameter("@IDDISTDOMICILIO", _BEIngresoTRegistro.IDDISTDOMICILIO));
                sqlCommand.Parameters.Add(new SqlParameter("@CODIGOCLASEPLANILLA", _BEIngresoTRegistro.CODIGOCLASEPLANILLA));

                sqlCommand.Parameters.Add(new SqlParameter("@FECHAINGRESO", _BEIngresoTRegistro.FECHAINGRESO));
                sqlCommand.Parameters.Add(new SqlParameter("@IDCATEGORIASEMPLEADO", _BEIngresoTRegistro.IDCATEGORIASEMPLEADO));

                sqlCommand.Parameters.Add(new SqlParameter("@IDTIPOCONTRATO", _BEIngresoTRegistro.IDTIPOCONTRATO));
                sqlCommand.Parameters.Add(new SqlParameter("@SALARIORECIBO", _BEIngresoTRegistro.SALARIORECIBO));

                using (DataAccess adoDataService = new DataAccess())
                {
                    adoDataService.BeginTransaction();
                    //Int32 orderID = adoDataService.ExecuteScalar(sqlCommand);
                    adoDataService.ExecuteNonQuery(sqlCommand);
                    adoDataService.CommitTransaction();
                    adoDataService.Dispose();

                    //oPersonal.IDPERSONAL = orderID;
                }

            }
            catch (Exception ex)
            {

            }

            return 1;



        }

    }
}
